using System;
using System.ComponentModel;
using System.Linq.Expressions;

namespace PropertyExpression.CalcExpression
{
    public static class Util2
    {
        public static NewPropertyHolder<TEntity, TProperty> NewPropertyHolder<TEntity, TProperty>(
            this TEntity entity, 
            Expression<Func<TEntity, TProperty>> expression,
            Action onChangeAction) 
            where TEntity : INotifyPropertyChanged
        {
            return new NewPropertyHolder<TEntity, TProperty>(entity, expression, onChangeAction);
        }

        public static void AddCalcs(Action<CalcBinder> action)
        {
            var calcBinder = new CalcBinder();
            action(calcBinder);
            calcBinder.BeginCalc();
        }

        public static TEntity Create<TEntity>() where TEntity : ICalcEntity, new()
        {
            var entity = new TEntity();
            entity.AddCalc();
            return entity;
        }
    }

    public interface ICalcEntity
    {
        void AddCalc();
    }
}